package main

import (
	"hello/lib"
	"io/ioutil"
	"log"
	"net/http"
	"strings"
)

var WxMenuUrl = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="
var MenuText = `
{
	"button":[
	{
		"name":"我的物联",
		"sub_button":[
		{	
			"type":"view",
			"name":"首页",
			"url":"http://www.dcharles.work/home"
		},
		{
			"type":"view",
			"name":"子菜单2",
			"url":"http://www.qq.com"
		},
		{
			"type":"view",
			"name":"子菜单3",
			"url":"http://www.baidu.com"
		}]
	},
	{
		"name":"菜单2",
		"sub_button":[
		{	
			"type":"view",
			"name":"子菜单1",
			"url":"http://www.soso.com/"
		},
		{
			"type":"view",
			"name":"子菜单2",
			"url":"http://www.qq.com"
		},
		{
			"type":"view",
			"name":"子菜单3",
			"url":"http://www.baidu.com"
		}]
	}]
}

`
func main()	{
	token := lib.GetAccessToken()

	resp, err := http.Post(WxMenuUrl + token, "application/json", strings.NewReader(MenuText))
	defer resp.Body.Close()
	if err != nil {
		log.Printf("post menu text error :%s", err)
	}
	res, err := ioutil.ReadAll(resp.Body)

	log.Printf("set menu response :%s", string(res))


	//token, _ := lib.AcquireAccessToken()
	//fmt.Println(token)
}
